<template>
  <div>
    <el-container>
      <el-header>
        <span>公司概览</span>
      </el-header>
    </el-container>
    <div class="graduate-info">
      <div class="campus-search">
        <el-form label-width="45px" v-model="searchForm" :inline="true">
          <el-form-item>
            <el-input
              type="text"
              placeholder="你想知道什么呢"
              v-model="searchForm.searchParams"
              style="width: 150px; margin-left: 30px; margin-top: 45px"
              auto-complete="off"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button
              plain
              type="primary"
              icon="el-icon-search"
              style="margin-top: 45px"
              @click="search"
            ></el-button>
          </el-form-item>
        </el-form>
      </div>
      <el-divider>company</el-divider>
      <div v-for="item in list" :key="item.eid">
        <el-descriptions
          style="color: red"
          :title="item.ename"
          :column="3"
          border
        >
          <template slot="extra">
            <el-button
              type="text"
              size="small"
              @click="viewPosition(item.ename)"
              >相关职位</el-button
            >
          </template>
          <el-descriptions-item label="公司名称">{{
            item.ename
          }}</el-descriptions-item>
          <el-descriptions-item label="创始人">{{
            item.founder
          }}</el-descriptions-item>
          <el-descriptions-item label="创始人年龄">{{
            item.fonderage
          }}</el-descriptions-item>
          <el-descriptions-item label="成立时间">
            <el-date-picker readonly v-model="item.buildtime" type="date">
            </el-date-picker>
          </el-descriptions-item>
          <el-descriptions-item label="地址">{{
            item.eaddress
          }}</el-descriptions-item>
          <el-descriptions-item label="公司类别">{{
            item.eclass
          }}</el-descriptions-item>
          <el-descriptions-item label="企业文化">{{
            item.corporateculture
          }}</el-descriptions-item>
        </el-descriptions>
        <el-divider><i class="el-icon-more"></i></el-divider>
      </div>
    </div>
    <el-container>
      <el-footer>
        <div>
          <span>专注于互联网校招</span>
        </div>
      </el-footer>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "RecommendGraduatecompany",

  data() {
    return {
      list: [],
      searchForm: {
        searchParams: "",
      },
    };
  },

  mounted() {
    this.loadList();
  },

  watch: {
    "searchForm.searchParams": function (newVal) {
      if (newVal === "") {
        this.loadList();
      } else {
        return;
      }
    },
  },

  methods: {
    loadList() {
      this.$axios
        .post("/enterpriseInfo/queryAllEnterpriseInfo")
        .then((result) => {
          if (result.data.result != null) {
            this.list = result.data.result;
          } else {
            return;
          }
        })
        .catch((err) => {
          console.log(err);
          this.$message({
            message: "系统错误!!!",
            type: "error",
          });
        });
    },

    search() {
      if (this.searchForm.searchParams === "") {
        this.$message({
          message: "无输入",
          type: "error",
        });
        return;
      }

      this.$axios
        .post("/enterpriseInfo/search", this.searchForm)
        .then((res) => {
          if (res.data.result != null) {
            this.list = res.data.result;
          } else {
            return;
          }
        })
        .catch((err) => {
          console.log(err);
          this.$message({
            message: "系统错误!!!",
            type: "error",
          });
        });
    },

    viewPosition(name) {
      this.$router.push({
        name: "graduatePosition",
        params: {
          ename: name,
        },
      });
    },
  },
};
</script>

<style scoped>
.el-header {
  background-color: #409eff;
  color: white;
  line-height: 60px;
}

.el-footer {
  background-color: #409eff;
  color: white;
  line-height: 60px;
}

.el-footer div {
  margin-left: 43%;
}

.graduate-info {
  margin-top: 10px;
  margin-bottom: 10px;
  height: 480px;
  background: whitesmoke;
  /* background-image: url(https://img2.baidu.com/it/u=2699034911,1369297825&fm=253&fmt=auto&app=138&f=JPEG?w=890&h=500); */
  /* background-size: 1355px 480px; */
  overflow: auto;
}
</style>
